set(LIBSSH_TAG "libssh-0.10.6" CACHE STRING "libssh git tag")
set(LIBSSH_URL "https://www.libssh.org/files/0.10/${LIBSSH_TAG}.tar.xz" CACHE STRING "libssh source tarball")

set(LIBSSH_INSTALL_DIR ${CMAKE_BINARY_DIR}/libssh/install)

# LibSSH is LGPL.
ExternalProject_Add(libssh
        URL ${LIBSSH_URL}
        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBSSH_INSTALL_DIR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
        -DCMAKE_C_FLAGS=-fPIC -DBUILD_SHARED_LIBS=N -DWITH_GSSAPI=N -DCMAKE_INSTALL_LIBDIR=lib
        SOURCE_DIR ${CMAKE_BINARY_DIR}/libssh/source
        BINARY_DIR ${CMAKE_BINARY_DIR}/libssh/build
        INSTALL_DIR ${LIBSSH_INSTALL_DIR}
        UPDATE_COMMAND ""
        LOG_OUTPUT_ON_FAILURE 1
        LOG_DOWNLOAD 1
        LOG_UPDATE 1
        LOG_CONFIGURE 1
        LOG_BUILD 1
        LOG_INSTALL 1)

set(LIBSSH_FOUND TRUE)
set(LIBSSH_LIBRARY ${LIBSSH_INSTALL_DIR}/lib/libssh.a)
set(LIBSSH_INCLUDE_DIR ${LIBSSH_INSTALL_DIR}/include)
